.class public Lcom/teewoo/app/bus/util/weather/WeatherUtil;
.super Ljava/lang/Object;
.source "WeatherUtil.java"


# static fields
.field public static final WEATHERURL:Ljava/lang/String; = "http://doudou360.com:8081/GoogleWeather.ashx?city=,,,"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 25
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getGoogleUrl(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 2
    .parameter "latitude"
    .parameter "longitude"

    .prologue
    .line 40
    new-instance v0, Ljava/lang/StringBuilder;

    const-string v1, "http://doudou360.com:8081/GoogleWeather.ashx?city=,,,"

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, ","

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, "&vstr=49CD33452EECE82032FB3222ED64BCDA"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public static getWeather(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/teewoo/app/bus/model/weather/City;
    .locals 12
    .parameter "ctx"
    .parameter "cityName"
    .parameter "latitude"
    .parameter "longitude"

    .prologue
    .line 53
    new-instance v0, Lcom/teewoo/app/bus/model/weather/City;

    invoke-direct {v0}, Lcom/teewoo/app/bus/model/weather/City;-><init>()V

    .line 54
    .local v0, city:Lcom/teewoo/app/bus/model/weather/City;
    invoke-virtual {v0, p2}, Lcom/teewoo/app/bus/model/weather/City;->setLat(Ljava/lang/String;)V

    .line 55
    invoke-virtual {v0, p3}, Lcom/teewoo/app/bus/model/weather/City;->setLon(Ljava/lang/String;)V

    .line 56
    invoke-static {}, Lcom/teewoo/app/bus/util/Utils;->getLocCurrentTime()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v0, v10}, Lcom/teewoo/app/bus/model/weather/City;->setUpdateTime(Ljava/lang/String;)V

    .line 57
    invoke-virtual {v0, p1}, Lcom/teewoo/app/bus/model/weather/City;->setName(Ljava/lang/String;)V

    .line 60
    :try_start_0
    new-instance v8, Ljava/net/URL;

    invoke-static {p2, p3}, Lcom/teewoo/app/bus/util/weather/WeatherUtil;->getGoogleUrl(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v10

    invoke-direct {v8, v10}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 62
    .local v8, url:Ljava/net/URL;
    invoke-static {}, Ljavax/xml/parsers/SAXParserFactory;->newInstance()Ljavax/xml/parsers/SAXParserFactory;

    move-result-object v2

    .line 63
    .local v2, factory:Ljavax/xml/parsers/SAXParserFactory;
    invoke-virtual {v2}, Ljavax/xml/parsers/SAXParserFactory;->newSAXParser()Ljavax/xml/parsers/SAXParser;

    move-result-object v5

    .line 64
    .local v5, parser:Ljavax/xml/parsers/SAXParser;
    invoke-virtual {v5}, Ljavax/xml/parsers/SAXParser;->getXMLReader()Lorg/xml/sax/XMLReader;

    move-result-object v9

    .line 65
    .local v9, xmlreader:Lorg/xml/sax/XMLReader;
    new-instance v3, Lcom/teewoo/app/bus/model/weather/WeatherSAXParse;

    invoke-direct {v3}, Lcom/teewoo/app/bus/model/weather/WeatherSAXParse;-><init>()V

    .line 66
    .local v3, handler:Lcom/teewoo/app/bus/model/weather/WeatherSAXParse;
    invoke-interface {v9, v3}, Lorg/xml/sax/XMLReader;->setContentHandler(Lorg/xml/sax/ContentHandler;)V

    .line 67
    invoke-virtual {v8}, Ljava/net/URL;->openStream()Ljava/io/InputStream;

    move-result-object v7

    .line 69
    .local v7, stream:Ljava/io/InputStream;
    new-instance v6, Ljava/io/InputStreamReader;

    const-string v10, "utf-8"

    invoke-direct {v6, v7, v10}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;Ljava/lang/String;)V

    .line 70
    .local v6, reader:Ljava/io/InputStreamReader;
    new-instance v4, Lorg/xml/sax/InputSource;

    invoke-direct {v4, v6}, Lorg/xml/sax/InputSource;-><init>(Ljava/io/Reader;)V

    .line 71
    .local v4, is:Lorg/xml/sax/InputSource;
    invoke-interface {v9, v4}, Lorg/xml/sax/XMLReader;->parse(Lorg/xml/sax/InputSource;)V

    .line 72
    invoke-virtual {v3}, Lcom/teewoo/app/bus/model/weather/WeatherSAXParse;->getWeather()Lcom/teewoo/app/bus/model/weather/Weather;

    move-result-object v10

    invoke-virtual {v0, v10}, Lcom/teewoo/app/bus/model/weather/City;->setCityweather(Lcom/teewoo/app/bus/model/weather/Weather;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 77
    .end local v2           #factory:Ljavax/xml/parsers/SAXParserFactory;
    .end local v3           #handler:Lcom/teewoo/app/bus/model/weather/WeatherSAXParse;
    .end local v4           #is:Lorg/xml/sax/InputSource;
    .end local v5           #parser:Ljavax/xml/parsers/SAXParser;
    .end local v6           #reader:Ljava/io/InputStreamReader;
    .end local v7           #stream:Ljava/io/InputStream;
    .end local v8           #url:Ljava/net/URL;
    .end local v9           #xmlreader:Lorg/xml/sax/XMLReader;
    :goto_0
    return-object v0

    .line 73
    :catch_0
    move-exception v10

    move-object v1, v10

    .line 74
    .local v1, e:Ljava/lang/Exception;
    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V

    .line 75
    const-string v10, "Error"

    invoke-virtual {v1}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v11

    invoke-static {v10, v11}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0
.end method
